package com.he.controller;

import com.he.entity.Cook;
import com.he.entity.Result;
import com.he.service.CookService;
import com.he.util.PageBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/cook")
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE, RequestMethod.OPTIONS,RequestMethod.PATCH})
public class CookController {
    @Autowired
    private CookService cookService;

    @GetMapping("/foodInfo")
    public Result<PageBean<Cook>> foodInfo(int pageNum, int pageSize, @RequestParam(required = false) String foodName, @RequestParam(required = false) String foodType){
        log.info("调用所有的菜谱名");

        PageBean<Cook> list = cookService.pageList(pageNum,pageSize,foodName,foodType);
        return Result.success(list);
    }

}
